define('pc/js/mod/ucenter/vue-account-creditlog', [
    'pc/js/mod/vue-loading',
    'pc/js/mod/vue-empty',
    'components/VuePage/vue-page',
    'utils/Time',
    'utils/fetchEnhancer'], (VueLoading, VueEmpty, VuePage, Time, fetch) => {

Vue.prototype.Time = Time;

const VueAccountCreditLog = {
    props: ['strUid'],
    data: function() {
        return {
            loading: true,
            list: null,
            totalRecords: 0,
            pageSize: 10
        }
    },
    components: {
        'vue-loading': VueLoading,
        'vue-empty': VueEmpty,
        'vue-page': VuePage
    },
    methods: {
        fetchData: function(page) {
            fetch('/api/account/listcreditlog?page=' + page).then((res) => {
                if(0 === res.status) {
                    this.loading = false;
                    this.list = res.data.data;
                    this.pageSize = res.data.page_size;
                    this.totalRecords = res.data.total;
                }
            });
        },
        changePage: function(currentPage) {
            this.fetchList(currentPage);
        }
    },
    mounted: function() {
        this.fetchData(1);
    },
    template:
`<div>
    <h2 class="uc-itemtitle">日志（展示最近一个月）</h2>
    <div class="uc-content-wrapper">
        <vue-loading v-if="loading"></vue-loading>
        <vue-empty v-if="!loading && !list"></vue-empty>
        <table v-if="!loading && list" class="x-table">
            <tr><td>余额</td><td>积分</td><td>经验值</td><td>行为</td><td>说明</td><td>日期</td></tr>
            <tr v-for="item in list">
                <td>{{ item.money > 0 ? ('+' + item.money) : item.money }}</td>
                <td>{{ item.score > 0 ? ('+' + item.score) : item.score }}</td>
                <td>{{ item.experience > 0 ? ('+' + item.experience) : item.experience }}</td>
                <td>{{ item.action_name }}</td>
                <td>{{ item.reason }}</td>
                <td>{{ Time.format('y-m-d h:i:s', item.log_time * 1000) }}</td>
            </tr>
        </table>
        <vue-page v-bind:onChange="changePage" v-bind:totalRecords="totalRecords" v-bind:pageSize="pageSize"></vue-page>
    </div>
</div>`
};

return VueAccountCreditLog;

});
